package com.come4loves.game.module.skill.skillactorimpl;

import org.springframework.stereotype.Component;

import com.come4loves.core.utils.Splitable;
import com.come4loves.game.module.card.constant.CardType;
import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.module.fight.model.FightContext;
import com.come4loves.game.module.skill.AbstractSkillActorParser;
import com.come4loves.game.module.skill.model.SkillModel;
@Component
public class SummonUnitSkill extends AbstractSkillActorParser {

	@Override
	public String skillId() {
		return "summonunit";
	}

	@Override
	public void handerSkill(SkillModel skillModel, FightContext fightContext) {
		String[] temp = skillModel.getEffect().get(skillId()).split(Splitable.BETWEEN_DOT);
		for (String uid : temp) {
			FightCard card = FightCard.valueOf(CardType.UNIT, Integer.valueOf(uid));
			card.setId(fightContext.beActorBattle.getIdCreater().incrementAndGet());
			card.setSummon(true);
			fightContext.beActorBattle.summonUnit(fightContext.actionRecorder, card, fightContext.allActorBattles);
		}
	}

}
